package com.learning.concurrent.basic.singleton;

/**
 * description:
 *	静态内部类单例
 * @author minghuiZhang
 * @date created in  17:10 2018/5/10
 * modified by
 */
public class InnerSingleton {
	private static class Singleton{
		private static Singleton singleton = new Singleton();
	}
	public static Singleton getInstance(){
		return Singleton.singleton;
	}

	public static void main(String[] args) {
		Thread t1 = new Thread(new Runnable() {
			@Override
			public void run() {
				System.out.println(InnerSingleton.getInstance().hashCode());
			}
		},"t1");
		Thread t2 = new Thread(new Runnable() {
			@Override
			public void run() {
				System.out.println(InnerSingleton.getInstance().hashCode());
			}
		},"t2");
		Thread t3 = new Thread(new Runnable() {
			@Override
			public void run() {
				System.out.println(InnerSingleton.getInstance().hashCode());
			}
		},"t3");

		t1.start();
		t2.start();
		t3.start();
	}
}
